package com.ddwl.common.feign.wx;

import com.ddwl.schema.vo.base.WxRestVo;
import com.ddwl.schema.vo.gate.wechat.WxMinAppSessionVo;
import com.ddwl.schema.vo.gate.wechat.WxTokenVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Fu Zhaohui
 * @version 1.0.0
 * @date 2021/6/2 17:26
 */
@Api(tags = "微信用户API")
@FeignClient(name = "WxAuthApi", path = "/sns", url = "https://api.weixin.qq.com")
public interface WxAuthApi {

    @ApiOperation("通过 code 获取 access_token")
    @GetMapping("/oauth2/access_token")
    WxTokenVo oauth2(@RequestParam("appid") String appid, @RequestParam("secret") String secret, @RequestParam("code") String code, @RequestParam("grant_type") String grant_type);

    @ApiOperation("检验授权凭证（access_token）是否有效")
    @GetMapping("/auth")
    WxRestVo auth(@RequestParam("access_token") String access_token, @RequestParam("openid") String openid);

    @ApiOperation("获取用户个人信息（UnionID 机制）")
    @GetMapping("/userinfo")
    WxRestVo userinfo(@RequestParam("access_token") String access_token, @RequestParam("openid") String openid);

    @ApiOperation("小程序登录凭证校验")
    @GetMapping("/jscode2session")
    WxMinAppSessionVo jscode2session(@RequestParam("appid") String appid, @RequestParam("secret") String secret,
                                     @RequestParam("js_code") String js_code, @RequestParam("grant_type") String grant_type);
}
